﻿using Domain.Entities;
using JFnetcore.Models.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace JFnetcore.CS
{
    public class vArticleHelp
    {
        public List<vArticle> GetVArticleList(List<Article> Articlelist, List<ArticleType> Articletypelist, List<User> Userlist)
        {
            var vlist = from a in Articlelist
                        join b in Articletypelist
                        on a.ArticleType_Id equals b.Id
                        join c in Userlist
                        on a.User_Id equals c.Id
                        where a.Disable != 0
                        select new
                        {
                            Article_Id = a.Id,
                            Article_name = a.Article_name,
                            Article_Createtime = a.Createtime,
                            Article_txt = a.Article_txt,
                            ArticleType_Name = b.ArticleType_name,
                            Article_disable = a.Disable,
                            Article_disabledesc = a.Disabledesc,
                            Admin_remark =a.Admin_remark,
                            Admin_Createtime=a.Admin_Createtime,
                            Admin_step=a.Admin_step,
                            Admin_Id=a.Admin_Id,
                            User_id=a.User_Id,
                            User_name=c.User_name

                        };
            return vlist.ToList().Select(C => new vArticle
            {
                Article_id = C.Article_Id,
                Article_name = C.Article_name,
                Article_Createtime = C.Article_Createtime,
                Article_txt = C.Article_txt,
                ArticleType_name = C.ArticleType_Name,
                Article_disable = C.Article_disable,
                Article_disabledesc=C.Article_disabledesc,
                Admin_remark = C.Admin_remark,
                Admin_Createtime = C.Admin_Createtime,
                Admin_step = C.Admin_step,
                Admin_Id = C.Admin_Id,
                User_id = C.User_id,
                User_name = C.User_name
            }).ToList();
        }
    }
}
